package top.jimc.wsi.api.impl;

import top.jimc.wsi.api.HelloWService;
import top.jimc.wsi.entity.Person;

import javax.jws.WebService;
import javax.xml.ws.Endpoint;
import java.util.Date;

/**
 * WebService接口实现
 * @author Jimc.
 * @since 2018/8/31.
 */
@WebService(endpointInterface = "top.jimc.wsi.api.HelloWService",
            portName = "HelloWSoap",
            serviceName = "HelloWService",
            targetNamespace = "http://wsi.jimc.top/api/hello")
public class HelloWServiceImpl implements HelloWService {

    @Override
    public Integer add(Integer x, Integer y) {
        return x + y;
    }

    @Override
    public Date now() {
        return new Date();
    }

    @Override
    public Person getPerson(String name, Integer age) {
        Person person = new Person();
        person.setName(name);
        person.setAge(age);
        return person;
    }


    /**
     * 手动发布服务
     */
    public static void main(String[] args) {
        /*
         * 参数1：服务的发布地址
         * 参数2：服务的实现者
         */
        Endpoint.publish("http://127.0.0.1:8080/api/hello", new HelloWServiceImpl());

    }
}
